/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
func searchBST(root *TreeNode, val int) *TreeNode {
    if root == nil {
        return nil
    }
    var ans *TreeNode

    queue := list.New()
    queue.PushBack(root)

    for queue.Len() > 0 {
        node := queue.Remove(queue.Front()).(*TreeNode)
        if node.Val > val && node.Left != nil{
            queue.PushBack(node.Left)
        } else if node.Val < val && node.Right != nil {
            queue.PushBack(node.Right)
        } else if node.Val == val{
            ans = node
        }
    }

    return ans
}